/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ps.yj.y1j0.rest;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

import org.jboss.resteasy.annotations.cache.NoCache;
import ps.yj.y1j0.business.KVData.YJKVDataHandler;
import ps.yj.y1j0.business.YJDataHandler;
import ps.yj.y1j0.data.YJResult;

import java.sql.SQLException;

/**
 * @author yanjun
 */
@Path("/delete")
@NoCache
public class YJRestDelete {
    @DELETE
    @Path("/kv/{name}/{ids}")
    @Produces(MediaType.APPLICATION_JSON)
    public YJResult deleteKVData(@PathParam("name") String name, @PathParam("ids") String ids) {
        YJResult resultData = new YJResult();
        YJDataHandler handler = new YJKVDataHandler(name, "rowid");
        int result = 0;
        result = handler.delete(ids.split(","));
        resultData.setStatus(result > 0 ? Boolean.TRUE : Boolean.FALSE);
        resultData.setMessage(result > 0 ? "删除成功！" : "删除失败！");
        return resultData;
    }
}
